"""
 encoding    : utf-8
 @File       : logincommon.py
 @Author     : qin
 @Version    :
 @Description:
 @Date       : 2024/06/19
"""
from common.commonfunctions import Common
import time

class LoginCommon:
    '''登录页面基础类'''
    def __init__(self, driver):
        self.driver = driver

    def openWeb(self, url):
        '''打开浏览器'''
        self.driver.get(url)

    def login(self, uname, pwd):
        '''登录的基本页面操作'''
        user_ele = Common.getElement(self.driver, 'xpath',
                                     '/html/body/div/div[5]/form/div/div[2]/table/tbody/tr[1]/td[2]/input')
        user_ele.send_keys(uname)
        # 定位密码文本框
        pwd_ele = Common.getElement(self.driver, 'xpath',
                                    '/html/body/div/div[5]/form/div/div[2]/table/tbody/tr[2]/td[2]/input')
        pwd_ele.send_keys(pwd)
        # 定位登录按钮
        Common.getElement(self.driver, 'id', 'button_submit').click()
        time.sleep(1)

    def quitWeb(self):
        '''退出浏览器'''
        self.driver.quit()
